package org.rust.lang;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import junit.framework.TestCase;

public class TestOperatorExpressions extends TestBase
{
   public void XtestExecScripts() throws IOException
   {
      File dir = new File("U:\\work\\dev\\rust\\tests");      
      for (File file : dir.listFiles())
      {
         try
         {
            Rst.execScript(file.getAbsolutePath());
         }
         catch (FileNotFoundException e)
         {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }
     }
   }

   public void testSumPair()
   {
      assertEquals(3, execInt("sum(2 1)"));      
   }

   public void testSumMul()
   {
      assertEquals(8, execInt("sum(2 mul(3 2))"));      
   }

   public void testSumPair2()
   {
      assertEquals(3, execInt("+(2 1)"));      
   }

   public void testSumMul2()
   {
      assertEquals(8, execInt("+(2 *(3 2))"));      
   }

   public void testSumInfix()
   {
      assertEquals(3, execInt("(2 + 1)"));      
   }

   public void testSumInfixMultiple()
   {
      assertEquals(5, execInt("(2 + 1 + 2)"));      
   }

   public void testMultipleInfixMultiple()
   {
      assertEquals(51, execInt("(1 + (5 * 2 * (2 + 1 + 2)))"));      
   }

   public void testTwoExpressions()
   {
      assertEquals(3, execInt("((1 + 4) (1 + 2))"));      
   }

   public void testNestedExpression()
   {
      //assertEquals(45, execInt("(3 * (3 * (3 + 2)))"));
      assertEquals(45, execInt("(3 * (((3 * ((3 + 2))))))"));      
   }   
//assertEquals(97, execInt("sum(2 mul(3 mul(5 6)) 5)"));   
}

